using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
 
namespace Champ
{
    //The screen that contains the action of the game
    public class GameplayScreen:Screen
    {
        LootScreen loot = new LootScreen();
        PauseScreen pauseScreen = new PauseScreen();
        //Draws the screen
        public override void DrawScreen(SpriteBatch spriteBatch, GameController game)
        {

            this.renderingRect = game.titleSafe;
            //Draws background
            this.Draw(spriteBatch);
            //Draws players
            
            if (game.currentGameState == GameController.gameState.loot)
            {
                loot.DrawScreen(spriteBatch, game);
                /*   
                   if (game.playersTurn == 1)
                   {
                       if (game.outcome > 0)
                       {
                           DrawText(spriteBatch, new Vector2(400, 90), game.player[0].name + " Wins", game.gameFont[6], Color.White);
                       }
                       else
                       {
                           DrawText(spriteBatch, new Vector2(400, 90), game.player[0].name + " Loses", game.gameFont[6], Color.White);
                       }
                    
                   }
                   else if (game.playersTurn == 2)
                   {
                       if (game.outcome > 0)
                       {
                           DrawText(spriteBatch, new Vector2(400, 90), game.player[1].name + " Wins", game.gameFont[6], Color.White);
                       }
                       else
                       {
                           DrawText(spriteBatch, new Vector2(400, 90), game.player[1].name + " Loses", game.gameFont[6], Color.White);
                       }
                   }
                   else if (game.playersTurn == 3)
                   {
                       if (game.outcome > 0)
                       {
                           DrawText(spriteBatch, new Vector2(400, 90), game.player[2].name + " Wins", game.gameFont[6], Color.White);
                       }
                       else
                       {
                           DrawText(spriteBatch, new Vector2(400, 90), game.player[2].name + " Loses", game.gameFont[6], Color.White);
                       }
                   }
                   else
                   {
                       if (game.outcome > 0)
                       {
                           DrawText(spriteBatch, new Vector2(400, 90), game.player[3].name + " Wins", game.gameFont[6], Color.White);
                       }
                       else
                       {
                           DrawText(spriteBatch, new Vector2(400, 90), game.player[3].name + " Loses", game.gameFont[6], Color.White);
                       }
                   }*/
            }
            else if (game.paused == true)
            {
                pauseScreen.DrawScreen(spriteBatch, game);
            }

            else
            {
                if (game.playersTurn == 1)
                {
                    DrawText(spriteBatch, new Vector2(400, 90), game.player[0].name + "'s turn", game.gameFont[6], Color.White);
                }
                else if (game.playersTurn == 2)
                {
                    DrawText(spriteBatch, new Vector2(400, 90), game.player[1].name + "'s turn", game.gameFont[6], Color.White);
                }
                else if (game.playersTurn == 3)
                {
                    DrawText(spriteBatch, new Vector2(400, 90), game.player[2].name + "'s turn", game.gameFont[6], Color.White);
                }
                else
                {
                    DrawText(spriteBatch, new Vector2(400, 90), game.player[3].name + "'s turn", game.gameFont[6], Color.White);
                }

                //Text for the boxes at the bottom 
                DrawDynamicText(spriteBatch, new Vector2(102, 500), game.player[0].name,
                        75, game.gameFont, Color.White, 25);
                DrawDynamicText(spriteBatch, new Vector2(205, 500), game.player[1].name,
                        75, game.gameFont, Color.White, 25);
                DrawDynamicText(spriteBatch, new Vector2(310, 500), game.player[2].name,
                        75, game.gameFont, Color.White, 25);
                DrawDynamicText(spriteBatch, new Vector2(412, 500), game.player[3].name,
                        75, game.gameFont, Color.White, 25);
                DrawText(spriteBatch, new Vector2(102, 530), "Level: " + game.player[0].level,
                    game.gameFont[4], Color.White);
                DrawText(spriteBatch, new Vector2(205, 530), "Level: " + game.player[1].level,
                    game.gameFont[4], Color.White);
                DrawText(spriteBatch, new Vector2(310, 530), "Level: " + game.player[2].level,
                    game.gameFont[4], Color.White);
                DrawText(spriteBatch, new Vector2(412, 530), "Level: " + game.player[3].level,
                    game.gameFont[4], Color.White);

                //Text for monsters box at the bottom
                if (game.monsters[game.currentMonster].name.Length <= 11)
                {

                    DrawDynamicText(spriteBatch, new Vector2(635, 500), game.monsters[game.currentMonster].name,
                        75, game.gameFont, Color.White, 25);
                }
                else
                {
                    if (game.monsters[game.currentMonster].name == "Young Dragon")
                    {
                        DrawText(spriteBatch, new Vector2(635, 500), "Young",
                        game.gameFont[5], Color.White);
                        DrawText(spriteBatch, new Vector2(635, 520), "Dragon",
                         game.gameFont[5], Color.White);
                    }
                    else if (game.monsters[game.currentMonster].name == "Young Dark Dragon")
                    {
                        DrawText(spriteBatch, new Vector2(635, 500), "Young",
                        game.gameFont[0], Color.White);
                        DrawText(spriteBatch, new Vector2(635, 515), "Dark Dragon",
                         game.gameFont[0], Color.White);
                    }
                }
                DrawText(spriteBatch, new Vector2(635, 530), "Level: " + game.monsters[game.currentMonster].level,
                    game.gameFont[4], Color.White);

                game.player[0].Draw(spriteBatch);
                game.player[1].Draw(spriteBatch);
                game.player[2].Draw(spriteBatch);
                game.player[3].Draw(spriteBatch);
                //Draws monster
                game.monsters[game.currentMonster].Draw(spriteBatch);
            }
           

        }
        //Sets things where they belong
        public override void ScreenLayout(GameController game)
        {
            
        }
         

    }
}